package com.jackiechan.day18;

public class NeiWai {
    public static void main(String[] args) {
        Wai wai = new Wai();
        System.out.println(wai.waiString);
        wai.show();
//        wai.nei.show();
        System.out.println(wai.toString());
//        System.out.println(wai.nei.toString());
//        Wai.Nei nei = new Wai.Nei();
//        System.out.println(nei.neiString);
        Wai wai1 = new Wai(wai.nei);
        System.out.println(wai.nei.toString());
    }
}
class Wai{
    String waiString = "外部类String";
    Nei nei = new Nei();
    public Wai(){}
    public Wai(Nei nei){
        System.out.println("外部类把内部类当做参数的构造方法");
    }
    public void show(){
        Nei nei = new Nei(new Wai());
        System.out.println("外部类show()的 "+nei.neiString);
    }

    @Override
    public String toString() {
        return "Wai{" +
                "waiString='" + waiString + '\'' +
                ", nei=" + nei +
                '}';
    }

    class Nei{
        public Nei(){}
        public Nei(Wai wai){
            System.out.println("内部类把外部类当做参数的构造方法");
        };
        String neiString = "内部类String";
        public void show(){
            System.out.println("内部类show()的 "+"waiString");
        }

        @Override
        public String toString() {
            return "Nei{" +
                    "neiString='" + neiString + '\'' +
                    '}';
        }
    }
}
